﻿@using EmployeeLeaveSystem.Shared;
@using EmployeeLeaveSystem.Shared.Models;
@inject IMessageService _MessageService;
@inject HttpClient _HttpClient;

<h5>考勤打卡</h5>
<Descriptions Title="相关细则一览" Bordered Column="@column">
    <DescriptionsItem Title="编号">@addWork.Id</DescriptionsItem>
    <DescriptionsItem Title="申请人编号">
        @addWork.StaffId
    </DescriptionsItem>
    <DescriptionsItem Title="申请人姓名">
        @addWork.Staff?.Name
    </DescriptionsItem>
    <DescriptionsItem Title="上勤时间">
        @addWork.StartTime
    </DescriptionsItem>
    <DescriptionsItem Title="退勤时间">
        @addWork.StartTime
    </DescriptionsItem>
    <DescriptionsItem Title="接受状态">
        @addWork.AcceptFlag
    </DescriptionsItem>
    <DescriptionsItem Title="审核人">
        @addWork.AcceptStaff?.Name
    </DescriptionsItem>
    <DescriptionsItem Title="打卡状态">
        @addWork.workState
    </DescriptionsItem>
    <DescriptionsItem Title="发布时间">
        @addWork.Created
    </DescriptionsItem>
</Descriptions>
@code {

    [Parameter]
    public int Id { get; set; }
    AddWork addWork = new();

    protected override async Task OnParametersSetAsync() {
        try {
            addWork = await _HttpClient.GetFromJsonAsync<AddWork>($"api/Work/GetAddWorkById?id={Id}");
        }
        catch (Exception ex) {
            _MessageService.Error("获取信息失败");
            App._appHandle.NoticeWithIcon(NotificationType.Error, "失败", ex.Message);
        }
        InvokeAsync(StateHasChanged);
        _MessageService.Success("刷新数据成功");
    }
    // 样式布局
    private Dictionary<string, int> column = new Dictionary<string, int> {
            { "xxl", 3 },
            { "xl", 3},
            { "lg", 2},
            { "md", 2},
            { "sm", 1},
            { "xs", 1}
        };
}
